package  
{
	import flash.display.BitmapData;
	import flash.display.MovieClip;
	import flash.filters.GlowFilter;
	import flash.text.TextField;
	import flash.text.TextFormat;
	import flash.text.TextFormatAlign;
	import mx.core.BitmapAsset;
	/**
	 * ...
	 * @author KhanhNHV
	 */
	public class Square extends MovieClip
	{
		[Embed(source = "../lib/images.jpg")]
		private var Pattern:Class;
		[Embed(source = "../lib/Wood_floor_by_gnrbishop.jpg")]
		private var SpecialPattern:Class;	
		[Embed(source = "../lib/metal.jpg")]
		private var MetalPattern:Class;	
		
		private var roundCorner:Number = 0 ;
		private var cWidth :Number;
		private var cHieght:Number;
		private var isSpecial:Boolean;
		
		public function Square(width:Number,height:Number, roundCorner:Number, isSpecial:Boolean) 
		{
			this.isSpecial = isSpecial;
			var pattern:BitmapAsset
			this.roundCorner = roundCorner;
			cHieght = height;
			cWidth = width;
			if (isSpecial)
			{
				pattern =  new SpecialPattern() as BitmapAsset;
			}else
			{
				pattern = new Pattern() as BitmapAsset;
			}			 
			
			var bmpData:BitmapData = pattern.bitmapData;
			
			this.graphics.beginBitmapFill(bmpData);
			this.graphics.drawRoundRect(0, 0, width, height, roundCorner, roundCorner) ;
			this.graphics.endFill();			
		}
		
		public function disable():void
		{
			if (!this.isSpecial)
			{
				this.graphics.clear();
				var pattern:BitmapAsset;
				pattern = new MetalPattern() as BitmapAsset;	
				var bmpData:BitmapData = pattern.bitmapData;
				this.graphics.beginBitmapFill(bmpData);
				this.graphics.drawRoundRect(0, 0, cWidth, cHieght, roundCorner, roundCorner) ;
				this.graphics.endFill();
				
			}
			
		}
		
		public function highlightSpecial()
		{
			var glowFilter:GlowFilter = new GlowFilter(0xff00ff, 1, 40, 40, 100, 1);
			this.filters = [glowFilter];
		}
		
	}

}